package org.sport.repository;

import org.sport.model.entityModel.LocationtableEntity;
import org.sport.model.entityModel.SporthistorytableEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Allen on 2017/10/11.
 */

@Repository
public interface LocationRepository extends JpaRepository<LocationtableEntity,Integer> {


    /**
     * 通过查找SportHistory的Id来返回运动轨迹
     * @param spohisid
     * @return
     */
    @Transactional
    @Query("select locus from LocationtableEntity locus where locus.sporthistorytableBySpohisId =?1")
    public List<LocationtableEntity> findBySpoHisId(SporthistorytableEntity spohisid);


    /**
     * 通过查找SportHistory的Id来删除运动轨迹
     * @param spohisid
     * @return
     */
    @Modifying
    @Transactional
    @Query("delete from LocationtableEntity locus where locus.sporthistorytableBySpohisId =?1")
    public void delBySpoHisId(SporthistorytableEntity spohisid);


}
